<template>
  <div>
    <image-preview :src="imageList[0].trim()" />
    <el-button v-if="imageList.length > 1" size="mini" type="text" @click="viewMore = !viewMore">
      {{ viewMore ? "收起" : "查看更多照片" }}
    </el-button>
    <div v-if="viewMore" class="more-images">
      <div v-for="(url, index) in imageList.slice(1)" :key="index" class="image-preview">
        <image-preview :src="url.trim()" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ImagePreviewWithMore',
  props: {
    src: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      viewMore: false
    };
  },
  computed: {
    imageList() {
      return this.src.split(',');
    }
  }
};
</script>

<style scoped>
.more-images {
  margin-top: 10px;
}
.image-preview {
  display: inline-block;
  margin-right: 10px;
}
</style>
